package com.fhz.core_lib.dao;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;

import com.fhz.core_lib.entity.LoggedInUser;

import java.util.List;

/**
 * 时间:2021/11/25
 *
 * @author msfeng
 * 简述: room dao
 */
@Dao
public interface UserDao {

    @Query("SELECT * FROM user")
    LiveData<List<LoggedInUser>> getAll();

//    @Query("SELECT * FROM loggedInUser WHERE uid IN (:userIds)")
//    List<LoggedInUser> loadAllByIds(int[] userIds);

    @Query("SELECT * FROM user WHERE nickname = :nickname")
    LiveData<LoggedInUser> loadUserByNickname(String nickname);

//    @Query("SELECT * FROM user WHERE first_name LIKE :first AND " +
//            "last_name LIKE :last LIMIT 1")
//    LoggedInUser findByName(String first, String last);

    @Insert
    void insertAll(LoggedInUser... users);

    @Insert
    void insertUser(LoggedInUser users);

    @Delete
    void delete(LoggedInUser user);
}
